package com.doyled.jump.util;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

public class Drawing {
	/**
	 * Draw an image from its center
	 * @param g graphic object
	 * @param image source image
	 * @param x x coodinate
	 * @param y y coodinate
	 */
	public static void draw(Graphics g, BufferedImage image, float x, float y){
		float imageWidth = image.getWidth();
		float imageHeight = image.getHeight();
		float realX = x - imageWidth / 2;
		float realY = y - imageHeight / 2;
		g.drawImage(image, (int)realX, (int)realY, null);
	}
	
	/**
	 * Draw an image from its center width specific width and height
	 * @param g graphic object
	 * @param image source image
	 * @param x x coodinate
	 * @param y y coodinate
	 */
	public static void draw(Graphics g, BufferedImage image, float x, float y, int width, int height){
		float realX = x - width / 2;
		float realY = y - height / 2;
		boolean result = g.drawImage(image, (int)realX, (int)realY, width, height, null);
	}
}
